package com.aaa.demo10;

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author ${崔灿}
 * @date 2022/11/02 19:44
 **/

public class ALiBaBa {
    public static void main(String[] args) {
        /*
        int corePoolSize, 核心线程的个数
      int maximumPoolSize, 最大线程的个数
      long keepAliveTime, 线程对象空闲的时间
      TimeUnit unit, 空闲时间单位
      BlockingQueue<Runnable> workQueue：等待队列
         */
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(2,5,2000, TimeUnit.SECONDS , new LinkedBlockingDeque<>(3));
        for(int i=0;i<30;i++){
            final int a=i;
            threadPoolExecutor.submit(new Runnable() {
                @Override
                public void run() {
                    System.out.println(Thread.currentThread().getName()+"~~~~~~"+a);
                }
            });
        }
    }
}
